<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script type="text/javascript" src="/fuman/js/product.js"></script>
<script>
function showimages(id,t,s)
{
	$.post("/product/ajaxbutton", {"op": "showImages","id":id},
	  function(data){
			if(data)
			{
				var tmp="<div class=upload_preview>";
				for(var i=0;i<data.length;i++)
				{
					if(s==1)
					{
						var dels= "<div class=\"delnocss\" style='right:-15px;'><a href=\"#\" title=\"删除图片\"><img src=\"/fuman/images/no.gif\" onclick=\"delone("+data[i].id+",'productdevelop')\"></a></div>";	
					}else{
						var dels="";
					}
					tmp+=" <div style='border:1px;width:90px;  margin: 1em;float: left;position: relative;'><a href="+data[i].images_url+" target=_thank><img src='"+data[i].thumb_url+"' style=\"width:expression(this.width > 85 ? 85px : this.width)\"></a>"+dels+"</div>";
				}
				tmp+="</div>";
				$("#showimages").html(tmp);
			}
			
	   },"json");
	$("#MergeProductID").val(id);
	if(t==1)
	{
		$("#zyupload").hide();	
	}
	$('#showimagesform').modal('show');
		
}
function changstauts(id,status)
{
	if(confirm("你确认改变状态?"))
	{
	  $.post("/product/ajaxbutton", {"op": "channewproductgstauts","id":id,"status":status},
	  function(data){
				window.location.reload();
	   },"json");
	}	
}
function showthesample(id,status)
{
	$("#endorderlistst").html('');
	 $.post("/product/ajaxbutton", {"op": "getoneproductdata","id":id},
	  function(data){
				if(data)
				{
					$("#versiondivision").find("option[value="+data.versiondivision+"]").attr("selected",true);
					if(data.wages=='0.00')data.wages='';
					if(data.samplecosprice=='0.00')data.samplecosprice='';
					if(data.bulkprice=='0.00')data.bulkprice='';
					$("#wages").val(data.wages);
					$("#weight").val(data.weight);
					$("#cosprice").val(data.samplecosprice);
					$("#qualitymemo").val(data.qualitymemo);
					$("#bulkprice").val(data.bulkprice);
					$("#ck").val(data.ck);
					$("#samplememo").val(data.samplememo);
					var arr=new String();
					arr = data.bodystandard.split("+");
					for(var i=0;i<arr.length;i++)
					{
						$("#bodystandard"+arr[i]).attr("checked","checked");
					}
					if(data.sampleuser){
					$("#sampleuser").html("<tr><th>出样人：</th><td>"+data.sampleuser+"</td></tr>");
					}
					
					var material = data.material;
					 if (material.length > 0) {
						 var str ="";
                        for (var s = 0; s < material.length; s++) {
								var totalnum = s+1111;
							    str += "<tr id=las"+totalnum+">";
								str +="<td><span id=status"+totalnum+"></span><a href=javascript:void(0) onclick=delfiledsinput("+totalnum+")>移</a></td><td><input name=\"materialcode[]\" id=materialcode"+totalnum+" value='"+material[s].materialcode+"' placeholder=\"物料编号\" onBlur=\"getmaterialdata("+totalnum+")\"  class=\"width80\" type=\"text\"></td><td><input name=\"materialnum[]\" placeholder=\"数量\" value="+material[s].materialnum+" id=\"materialnum"+totalnum+"\" onBlur=\"getmaterialdata("+totalnum+")\" type=\"text\"  class=\"width100\">&nbsp;<input name=\"marterdw[]\" id=\"marterdw"+totalnum+"\" type=\"hidden\" ><span id=dw"+totalnum+"></span></td><td> <input name=\"materialtypename[]\" placeholder=\"物料名称\" id=\"materialtypename"+totalnum+"\" type=\"text\"  class=\"width100\" value="+material[s].materialtypename+"></td><td><input name=\"materialname[]\"  value='"+material[s].materialname+"' placeholder=\"物料名称\" id=\"materialname"+totalnum+"\" type=\"text\"  class=\"width100\"><td><input name=\"materwages[]\" placeholder=\"单价\"  value="+material[s].materwages+"  id=\"materwages"+totalnum+"\" type=\"text\"  class=\"width100\">&nbsp;<span id=materialprice"+totalnum+"></span></td>";
								str+="</tr>";
						}
						$("#endorderlistst").html(str);
                    }
					
					
				}
	   },"json");
	$("#MProductID").val(id);
	$("#MProductstatus").val(status);
	$('#showthesampleform').modal('show');	
}
function savechuyang()
{

	if($("#versiondivision").val()=='')
	{
		$("#versiondivisionerr").html('<font color=red>&nbsp;&nbsp;<B>必须选择打版师</B></font>');	
		$("#versiondivision").focus();
		return false;
	}else{
		$("#versiondivisionerr").html('');	
	}
	if($("#wages").val()=='0.00' || $("#wages").val()=='')
	{
		$("#wageserr").html('<font color=red>&nbsp;&nbsp;<B>请填写工价</B></font>');	
		$("#wageserr").focus();
		return false;	
	}else{
		$("#wageserr").html('');		
	}
	if($("#weight").val()==0 || $("#weight").val()==''){
		alert("重量必填");return false;
	}

	if($("#cosprice").val()=='0.00' || $("#cosprice").val()=='' )
	{
		$("#cospriceerr").html('<font color=red>&nbsp;&nbsp;<B>请填写成本价</B></font>');	
		$("#cospriceerr").focus();
		return false;	
	}else{
		$("#cospriceerr").html('');		
	}
	if($("#bulkprice").val()=='0.00' || $("#bulkprice").val()=='' )
	{
		$("#bulkpriceerr").html('<font color=red>&nbsp;&nbsp;<B>请填写批量价</B></font>');	
		$("#bulkprice").focus();
		return false;	
	}else{
		$("#bulkpriceerr").html('');		
	}
	var i=0;
	var str='';
	var vote_arr = document.getElementsByName("bodystandard[]");
	for(var j = 0; j < vote_arr.length; j++)
	{
	   if(vote_arr[j].checked == true)
	   {
		     str += vote_arr[j].value+"+";
		   i++;
	   } 
	}
	if(i<=0){
    	$("#bodystandarderr").html('<font color=red>&nbsp;&nbsp;<br><B>请选择主件质检信息</B></font>');	
     return false;
    }else{
		$("#bodystandarderr").html('');	
	}
	//判断物料编号 materialnum
	var materialnum_arr = document.getElementsByName("materialnum[]");
	if(materialnum_arr.length>0){
		for(var j = 0; j < materialnum_arr.length; j++)
		{
			if(materialnum_arr[j].value)
			{
			}else{
				alert("物料编号不能为空");return false;
			}
		}
	}

	if($("#qualitymemo").val()=='')
	{
		$("#qualitymemoerr").html('<font color=red>&nbsp;&nbsp;<B><br>质检信息必须填写</B></font>');	
		$("#qualitymemoerr").focus();
		return false;	
	}else{
		$("#qualitymemoerr").html('');		
	}
	if($("#ck").val()=='')
	{
		$("#ckerr").html('<font color=red>&nbsp;&nbsp;<B><br>面料信息必须填写</B></font>');	
		$("#ckerr").focus();
		return false;	
	}else{
		$("#ckerr").html('');		
	}
	var title = "主件质检信息: "+str+"\r\n其他质检信息:"+$("#qualitymemo").val()+"\r\n";
	if(confirm("请确认：\r\n"+title))
	{
	$('#showthesampleform').modal('hide');
	AWS.ajax_post($('#utimgtform'));	
	}
}


var totalnum = 1;
function showaddinput(t)
{
	$("#fileinput").html('');
	var inputn = document.getElementById(t);
	var str=inputn.innerHTML;
	var num=1;
	for(var i=1;i<=num;i++){
		totalnum=totalnum+i;
		
		str += "<tr id=las"+totalnum+">";
		str +="<td><span id=status"+totalnum+"></span><a href=javascript:void(0) onclick=delfiledsinput("+totalnum+")>移</a></td><td><input name=\"materialcode[]\" id=materialcode"+totalnum+" placeholder=\"物料编号\" onBlur=\"getmaterialdata("+totalnum+")\"  class=\"width80\" type=\"text\"></td><td><input name=\"materialnum[]\" placeholder=\"数量\" id=\"materialnum"+totalnum+"\" onBlur=\"getmaterialdata("+totalnum+")\"  type=\"text\"  class=\"width100\">&nbsp;<input name=\"marterdw[]\" id=\"marterdw"+totalnum+"\" type=\"hidden\" ><span id=dw"+totalnum+"></span></td><td><input name=\"materialtypename[]\" placeholder=\"物料名称\" id=\"materialtypename"+totalnum+"\" type=\"text\"  class=\"width100\"></td><td><input name=\"materialname[]\" placeholder=\"物料名称\" id=\"materialname"+totalnum+"\" type=\"text\"  class=\"width100\"><td><input name=\"materwages[]\" placeholder=\"单价\" id=\"materwages"+totalnum+"\" type=\"text\"  class=\"width100\">&nbsp;<span id=materialprice"+totalnum+"></span></td>";
		str+="</tr>";
		
	
	}
	$("#"+t).before(str);
	
}
function getmaterialdata(id)
{
	var materialcode = $("#materialcode"+id).val();//物料编号
	var materialnum  = $("#materialnum"+id).val();//物料数量
	if(materialcode)
	{
	 $.post("/product/ajaxbutton", {"op": "getmaterialcode","materialcode":materialcode,"materialnum":materialnum},
	  function(data){
			if(data == 201)
			{
				alert('没有找到该物料编号！');
				$("#materialcode"+id).val('');
				return false;
			}else{
				$("#materialtypename"+id).val(data.typename);
				$("#materialname"+id).val(data.projeck);
				$("#materwages"+id).val(data.price);
				$("#dw"+id).html(data.dw);
				$("#marterdw"+id).val(data.dw);
				if(data.materialprice)
				{
					$("#materialprice"+id).html(" 合计："+data.materialprice+" RMB");	
				}
			}
	   },"json");
	}
}
function delfiledsinput(id)
{
	if(confirm("确定移除？"))
	{
		$("#las"+id).remove();
	}
}
//推荐商品
function doRecommend(flag) {
	var str = selectallpro();
	if(str !=false)
	{
		if(flag==0){
			$("#extIds").val(str);
			$('#dorecommendform').show();
		}
		if(flag==1){
			var vote_arr = document.getElementsByName("receiver[]");
			var idarr = new Array();
			var i=0;
			var strs="";
			for(var j = 0; j < vote_arr.length; j++){
				if(vote_arr[j].checked == true){
					idarr[i] = vote_arr[j].value;
					strs += vote_arr[j].value+",";
					i++;
				}
			}
			if(i<=0){
				alert("未选中相关推荐者");
				return false;
			}
			$.post("/product/ajaxbutton", {"op": "doRecommendGoods","ids":str,"receiver":strs},
					function(data){
						if(data)
						{
							alert("推荐成功!");
							window.location.reload();
						}
					},"text");
		}

	}
}
function checkAll() {
	var arr_receiver = document.getElementsByName("receiver[]");
	for(var i = 0; i < arr_receiver.length; i++){
		if(arr_receiver[i].checked == true){
			arr_receiver[i].checked = false;
		}else{
			arr_receiver[i].checked = true;
		}
	}
}
function showreport(sku)
{
	$.post("/externalBuy/ajaxbutton", {"op": "showreport","sku":sku,"type":1},
		function(data){
			if(data == 201)
			{
				alert("暂无销售数据!");return false;	
			}else{
				$("#reportShowhtml").html(data);
				$('#returndataModal').modal('show');
			}
			
			alert(tmp);
		},"text");
}
</script>
<title>新品开发周期统计</title>
<body class="withvernav">
<div class="bodywrapper">
    {{include file='/public/leftmenu.tpl'}}
    <div class="centercontent">
        
        <!--pageheader-->

        <div id="contentwrapper" class="contentwrapper">
            <div id="basicform" class="subcontent">
	            
            <!--搜索栏-->
                <div class="page">{{$pageList}} 计{{$total}}条记录，共{{$totalpage}}页</div>

                <form class="stdform stdform2" method="get" id="search" action="/product/newproduct">
                    <input type='hidden' name='if_csv' id='if_csv'>

                    <div class="tableoptions">


                        <select name="ty" id="searchtype" class="selection" style="width:100px;">
                            <option value="1" {{if $ty==1}} selected{{/if}}>创建时间</option>
                            <option value="2" {{if $ty==2}} selected{{/if}}>完成时间</option>
                        </select>

                        <input type="text" name="starttime" value="{{$starttime}} "
                               onClick="WdatePicker({dateFmt:'yyyy-MM-dd '})" class="width100 hasDatepicker"/> - <input
                                type="text" name="endtime" value="{{$endtime}} "
                                onClick="WdatePicker({dateFmt:'yyyy-MM-dd '})" class="width100 hasDatepicker"/>
                        &nbsp;
                        来源工厂:
          <select class="selectCss2" name="factory_id" id="factory_id">
                            <option value="">请选择</option>
                            <option value="1" {{if $factory_id==1}} selected{{/if}}>工厂1</option>
                            <option value="2" {{if $factory_id==2}} selected{{/if}}>工厂2</option>
                            <option value="7" {{if $factory_id==7}} selected{{/if}}>其他</option>
                        </select>
                        &nbsp;
                        <button class="btn btn_orange btn_search radius50">Search</button>
                    </div>


                </form>
                <!--搜索栏结束-->
                <table cellpadding="0" cellspacing="0" border="0" class="stdtable">
                    <thead>
                    <tr class="lbbt">
                        <td width="5%" bgcolor="#f7f7f7"><a onClick="allSelect('ppid[]')">全选</a></td>
                        <td width="8%" bgcolor="#f7f7f7">新品编号</td>
                        <td width="10%" bgcolor="#f7f7f7">图片</td>
                        <td width="20%" bgcolor="#f7f7f7">商品信息</td>
                        <td width="5%" bgcolor="#f7f7f7">预售价</td>
                        <td width="5%" bgcolor="#f7f7f7">状态</td>
                        <td width="8%" bgcolor="#f7f7f7"><span class="cz">开发人</span>员</td>
                        <td width="5%" bgcolor="#f7f7f7">来源</td>
                        <td width="8%" bgcolor="#f7f7f7">创建/完成时间</td>
                        <td width="5%" bgcolor="#f7f7f7">开发周期</td>
                      </tr>
                    </thead>

                    {{foreach from=$goodslist item=li key=key}}
                    <tbody id="bdetail{{$detail.p_parent_id}}">
                    <tr>
                        <td><input name="ppid[]" type="checkbox" class="none" id="ppid[]" value="{{$li.id}}" onClick="showallchangsmod()"/></td>
                        <td valign="middle" style="position:relative;">
                         {{if $li.status==6}}<a href="/product/productlist?other={{$li.sku}}" target="_blank">{{$li.sku}}</a>{{else}}{{$li.sku}}{{/if}}                        </td>
                        <td valign="middle">
                        {{if $li.mod==1}}
                        	<a href="javascript:void(0)" onClick="showimages({{$li.id}},0,1)"><img src="{{$li.images}}" width="50"></a>
                        {{else}}
                       		 <a href="javascript:void(0)" onClick="showimages({{$li.id}},0,0)"><img src="{{$li.images}}" width="50"></a>
                        {{/if}}                        </td>
                        <td>
                            <div class="lbcp">
                                {{$li.name}}<br>
	                        <a href="{{$li.linkUrl}}" target="_blank"><font color="#FF0000">参考连接</font><img src="/fuman/images/icons/attachment.png"></a>
	                        {{/if}}                            </div>                        </td>

                        <td valign="middle">{{$li.saleprice}}</td>
                        <td class="cz">{{$li.statusst}}<br>                        	</td>
                        <td class="cz">{{$li.createName}}</td>
                        <td class="cz">{{if $li.supplier==1}}工厂1{{/if}}{{if $li.supplier==2}}工厂2{{/if}}{{if $li.supplier==3}}外采购{{/if}}
                        
                        {{if $li.supplier==7}}广州{{/if}}</td>
                        <td class="cz">
                        {{$li.instime}}<br>
                        {{$li.tbopertime}}</td>
                        <td class="cz">
                        
                          {{if $li.mod==1}}
                        	<a href="javascript:void(0)" onClick="showimages({{$li.id}},0,1)">样本图</a>
                        {{else}}
                       		 <a href="javascript:void(0)" onClick="showimages({{$li.id}},0,0)">样本图</a>
                        {{/if}}                       </td>
                    </tr>

                    {{/foreach}}
                </table>
              <div class="page">{{$pageList}} 计{{$total}}条记录，共{{$totalpage}}页</div>
            </div>
        </div>
        
</body>
</html>